# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""
#检测一个文件夹下的所有PDF文件一共有多少页
import os
from os import path
import PyPDF2

filePath=r"G:\ZJUzhanghaoyuData\机电系统分析与设计\新建文件夹"
fileLists=os.listdir(filePath)
def testPages(s):
    pdfFile=open(path.join(filePath,s),'rb')
    pdfReader=PyPDF2.PdfFileReader(pdfFile)
    return pdfReader.numPages
def main():
    sum=0
    for i in fileLists:
        a=testPages(i)
        print(a,i)
        sum=sum+a
    print("总页数：",sum)
    print("共有文件个数：",len(fileLists))
    
if __name__=="__main__":
    main()